import { createI18n } from 'vue-i18n';

// English translations
const en = {
    common: {
        save: 'Save',
        cancel: 'Cancel',
        delete: 'Delete',
        edit: 'Edit',
        add: 'Add',
        search: 'Search',
        logout: 'Logout',
        login: 'Login',
        register: 'Register'
    },
    dialogs: {
        languageChangeTitle: 'Language Setting Changed',
        languageChangeRefreshMessage: 'The language setting change requires a page refresh to take effect. Refresh now?',
        refresh: 'Refresh',
        refreshLater: 'Later'
    },
    settings: {
        title: 'Settings',
        userInfo: 'User Information',
        accountSettings: 'Account Settings',
        systemSettings: 'System Settings',
        username: 'Username',
        role: 'Role',
        email: 'Email',
        nickname: 'Nickname',
        saveUserInfo: 'Save User Information',
        locationName: 'Location Name',
        changePassword: 'Change Password',
        privacySettings: 'Privacy Settings',
        languageSettings: 'Language Settings',
        systemName: 'System Name',
        itemExpiryReminder: 'Item Expiry Reminder',
        inventoryWarning: 'Inventory Warning',
        dataUpdateReminder: 'Data Update Reminder',
        resetSettings: 'Reset Settings',
        saveSettings: 'Save Settings'
    },
    roles: {
        admin: 'Administrator',
        manager: 'Manager',
        member: 'Member',
        guest: 'Guest',
        unknown: 'Unknown'
    },
    messages: {
        settingsSaved: 'Settings saved',
        settingsReset: 'Settings have been reset',
        userInfoUpdated: 'User information updated',
        passwordChanged: 'Password changed successfully',
        logoutSuccess: 'Logged out successfully',
        logoutFailed: 'Logout failed',
        avatarSelected: 'Avatar selected, click "Save User Information" to save changes',
        locationNameUpdated: 'Location name updated successfully',
        insufficientPermissions: 'Insufficient permissions, only administrators or users with viewing permissions can modify the location name',
        locationUpdateTitle: 'Location Updated',
        locationUpdateRefresh: 'Location name has been updated. Refresh the page to see all changes?'
    },
    placeholders: {
        enterUsername: 'Enter username',
        enterEmail: 'Enter email',
        enterNickname: 'Enter nickname',
        currentLocationName: 'Current location name',
        selectLanguage: 'Select language',
        systemName: 'System name'
    }
};

// Chinese translations
const zh = {
    common: {
        save: '保存',
        cancel: '取消',
        delete: '删除',
        edit: '编辑',
        add: '添加',
        search: '搜索',
        logout: '退出登录',
        login: '登录',
        register: '注册'
    },
    dialogs: {
        languageChangeTitle: '语言设置已更改',
        languageChangeRefreshMessage: '修改语言设置需要刷新页面才能生效，是否现在刷新？',
        refresh: '刷新',
        refreshLater: '稍后刷新'
    },
    settings: {
        title: '设置',
        userInfo: '用户信息',
        accountSettings: '账号设置',
        systemSettings: '系统设置',
        username: '用户名',
        role: '身份',
        email: '邮箱',
        nickname: '昵称',
        saveUserInfo: '保存用户信息',
        locationName: '位置名称',
        changePassword: '修改密码',
        privacySettings: '隐私设置',
        languageSettings: '语言设置',
        systemName: '系统名称',
        itemExpiryReminder: '物品过期提醒',
        inventoryWarning: '库存预警',
        dataUpdateReminder: '数据更新提醒',
        resetSettings: '重置系统设置',
        saveSettings: '保存系统设置'
    },
    roles: {
        admin: '管理员',
        manager: '管理者',
        member: '成员',
        guest: '访客',
        unknown: '未知'
    },
    messages: {
        settingsSaved: '设置已保存',
        settingsReset: '设置已重置',
        userInfoUpdated: '用户信息已更新',
        passwordChanged: '密码修改成功',
        logoutSuccess: '退出登录成功',
        logoutFailed: '退出登录失败',
        avatarSelected: '头像已选择，点击"保存用户信息"按钮保存更改',
        locationNameUpdated: '位置名称更新成功',
        insufficientPermissions: '权限不足，只有管理员或有查看用户权限的用户可以修改位置名称',
        locationUpdateTitle: '位置已更新',
        locationUpdateRefresh: '位置名称已更新，刷新页面以查看所有更改？'
    },
    placeholders: {
        enterUsername: '输入用户名',
        enterEmail: '输入邮箱',
        enterNickname: '输入昵称',
        currentLocationName: '当前位置名称',
        selectLanguage: '选择语言',
        systemName: '系统名称'
    }
};

// Create i18n instance
const i18n = createI18n({
    legacy: false, // Use Composition API
    locale: localStorage.getItem('language') || 'zh-CN',
    fallbackLocale: 'zh-CN',
    messages: {
        'en-US': en,
        'zh-CN': zh
    },
    silentFallbackWarn: true,
    missingWarn: false
});

export default i18n; 